package com.fruit.controller.base;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.ModelAndView;

import com.fruit.util.ResultInfo;

/**
 * 
 * @ClassName: BaseController
 * @author 葛欢欢
 * @version 2017.11.30 12:20
 */
public class BaseController {

	protected Logger logger = LoggerFactory.getLogger(BaseController.class);

	static final long serialVersionUID = 6357869213649815390L;

	/**
	 * 得到ModelAndView
	 * 
	 * @return ModelAndView
	 */
	public ModelAndView getModelAndView() {
		return new ModelAndView();
	}

	/**
	 * 
	 * @param state
	 *            state
	 * @param code
	 *            code
	 * @param message
	 *            message
	 * @return ResultInfo
	 */
	public ResultInfo initResult(String state, String code, String message) {
		ResultInfo ri = new ResultInfo();
		ri.setState(state);
		ri.setCode(code);
		ri.setMessage(message);
		return ri;
	}

	/**
	 * 
	 * @param state
	 *            state
	 * @param code
	 *            code
	 * @param message
	 *            message
	 * @param url
	 *            url
	 * @return ResultInfo
	 */
	public ResultInfo initResult(String state, String code, String message, String url) {
		ResultInfo ri = new ResultInfo();
		ri.setState(state);
		ri.setCode(code);
		ri.setMessage(message);
		ri.setUrl(url);
		return ri;
	}

	/**
	 * 
	 * @param logge
	 *            logger
	 * @param interfaceName
	 *            interfaceName
	 */
	public void logBefore(Logger logge, String interfaceName) {
		logge.info("");
		logge.info("start");
		logge.info(interfaceName);
	}

	/**
	 * 
	 * @param logge
	 *            logger
	 * @param interfaceName
	 *            interfaceName
	 */
	public void logInfo(Logger logge, String interfaceName) {
		logge.info("");
		logge.info("info");
		logge.info(interfaceName);
	}

	/**
	 * 
	 * @param logge
	 *            logger
	 * @param interfaceName
	 *            interfaceName
	 */
	public void logWarn(Logger logge, String interfaceName) {
		logge.warn("");
		logge.warn("warn");
		logge.warn(interfaceName);
	}

	/**
	 * 
	 * @param logge
	 *            logger
	 * @param interfaceName
	 *            interfaceName
	 */
	public void logError(Logger logge, String interfaceName) {
		logge.error("");
		logge.error("error");
		logge.error(interfaceName);
	}

	/**
	 * 
	 * @param logge
	 *            logger
	 */
	public void logAfter(Logger logge) {
		logge.info("end");
		logge.info("");
	}
}
